package com.sinven.daoImpl;
import com.sinven.dao.OrderDao;
import com.sinven.entity.Order;
import com.sinven.dao.OrderDao;
import com.sinven.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 李志伟
 */
@Repository("orderDao")
public class OrderDaoImpl extends HibernateDaoSupport implements OrderDao {
    public OrderDaoImpl(){

    }
    @Autowired
    public OrderDaoImpl(@Qualifier("sessionFactory")SessionFactory sessionFactory){
        this.setSessionFactory(sessionFactory);
    }

    @Override
    public void addOrder(List<Order> order ,String hql) {

    }

    @Override
    public void updataOrder(List<Order> order ,String hql) {

    }

    @Override
    public void delectOrder(int id ,String hql) {

    }

    @Override
    public List<Order> findOrder(int id ,String hql) {
        Session session=HibernateUtil.getSession();
        Query query=session.createQuery(hql);
        query.setParameter(0,id);

        return query.list();

    }
    @Override
    public Integer savaOrder(Order order ,String hql) {
        return (Integer)this.getHibernateTemplate().save(order);
    }
}
   


